<script type="text/javascript">
//tab菜单
$("#tab").idTabs();
$(document).ready(function(){ 
　　get_fields(); 
});
//提交表单
savelistform({addurl:"__URL__/add/cid-{$class_info.cid}",listurl:"javascript:history.go(-1)"});
//TAG
$('#keywords').tagsInput(
{
	'defaultText':'关键词会转为tag'
});
$('.corol_button').soColorPacker({
	textChange:false, 
callback:function(c){
	$('#title').css("color", c.color);
	$('#font_color').val(c.color);
	}
});
//高级模式
function advanced(){
	$('.advanced').toggle();
}
function get_one_pic(){
	var content=editor_content.html();
	var imgreg = /<img.*?(?:>|\/>)/gi;
	var srcreg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
	var arr = content.match(imgreg);
	var src = arr[0].match(srcreg);
	$("#image").val(src[1]);
	}
function get_description(){
	var content=editor_content.text();
	content=content.substring(0,500);
	content=content.replace(/\s+/g," ")
	content=content.replace(/[\r\n]/g," ");
	content = content.replace(/<\/?[^>]*>/g,'');
	if(content.length > 250){
	    content = content.substring(0,250);
	}
	$("#description").val(content);
}
function get_keywords(){	
	ajaxpost_w({
		url:'__URL__/get_keyword',
		data:{title:$('#title').val(),content:$('#description').val()},
		tip:2,
		success:function(msg){
			$('#keywords').importTags(msg);
		},
		failure:function(){
		},
		msg:'关键词获取完毕'
	});
}
function get_remote_image(){
	ajaxpost_w({
		url:'__APP__/editor/get_remote_image',
		data:{content:editor_content.html()},
		tip:2,
		success:function(msg){
			editor_content.html(msg);
		},
		failure:function(){
		},
		msg:'远程抓图执行完毕'
	});
}
function fontbold()
{
	if($('#font_bold').val()==0){
		$('#title').css("font-weight",'bold');
		$('#font_bold').val(1);
		}else{
		$('#title').css("font-weight",'normal');	
		$('#font_bold').val(0);
	}
}
//获取附加字段
function get_fields() {
	var cid = $('#cid').val();
	var aid = '{$info.aid}';
	$.ajax({
		type: 'POST',
		url: "__APP__/expand_model/get_field",
		data: {
			cid: cid,
			aid: aid
		},
		dataType: "html",
		success: function(data) {
//			if(data==''){
//				var data='<tr><td width="100" align="left">暂无扩展信息</td><td width="350"></td><td></td></tr>';
//			}
			$('#expand').html(data);
		}
	})
}
//模板列表
function tpl_list(id){
	var list = [ 
	<!--foreach:{$tpl_list $vo}-->
	{
		href: "javascript:;\" onclick=\"tpl_val('"+id+"','{$vo}');\"",
		text: "{$vo}"
	},
	<!--{/foreach}-->
	{
		text: "请选择模板，支持子目录"
	}];
	return list;
	
}
//模板赋值
function tpl_val(id,val){
	$('#'+id).val(val);
	$.powerFloat.hide();
	return false;
}
//内容来源列表
function befrom_list(id){
	var list = [ 
	<!--foreach:{$befrom_list $vo}-->
	{
		href: "javascript:;\" onclick=\"befrom_val('"+id+"','{$vo}');\"",
		text: "{$vo}"
	},
	<!--{/foreach}-->
	{
		text: "请选择内容来源"
	}];
	return list;
	
}
//来源赋值
function befrom_val(id,val){
	$('#'+id).val(val);
	$.powerFloat.hide();
	return false;
}
//页面执行
$(document).ready(function() {
	//模板选择
	$("#tpl").powerFloat({
		width: 302,
		eventType: "click",
		edgeAdjust:false,
		target:tpl_list('tpl'),
		targetMode: "list"
	});
	//来源选择
	$("#copyfrom").powerFloat({
		width: 302,
		eventType: "click",
		edgeAdjust:false,
		target:befrom_list('copyfrom'),
		targetMode: "list"
	});
});
</script>